//
//  WSJConversion.m
//  WCN
//
//  Created by wsj2015 on 16/7/5.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WSJConversion.h"

@implementation WSJConversion


//重载选择 使用的LKDBHelper
+(LKDBHelper *)getUsingLKDBHelper
{
    static LKDBHelper* db;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
//                NSString* dbpath = [NSHomeDirectory() stringByAppendingPathComponent:@"asd/asd.db"];
//                db = [[LKDBHelper alloc]initWithDBPath:dbpath];
        //or
        db = [XHMessage getUsingLKDBHelper];
    });
    return db;
}
// 将要插入数据库
+(BOOL)dbWillInsert:(NSObject *)entity
{
    LKErrorLog(@"will insert : %@",NSStringFromClass(self));
    return YES;
}
//已经插入数据库
+(void)dbDidInserted:(NSObject *)entity result:(BOOL)result
{
    LKErrorLog(@"did insert : %@",NSStringFromClass(self));
}
//表名
+(NSString *)getTableName
{
    NSString *id =[[WCDefaultManager shareMg] account].stringId;
    return [NSString stringWithFormat:@"db_conversionList_%@",id];
}

- (instancetype)initWithMessage:(XHMessage *)message
{
    if (self  =[super init]) {
        self.fromId = message.sender;
        switch (message.messageMediaType) {
            case XHBubbleMessageMediaTypeText:
                self.detailText = message.text;
                break;
            case XHBubbleMessageMediaTypePhoto:
                self.detailText = @"图片";
                break;
            case XHBubbleMessageMediaTypeVideo:
                self.detailText = @"视频";
                break;
            case XHBubbleMessageMediaTypeVoice:
                self.detailText = @"语音";
                break;
                
            default:
                break;
        }

        self.unread = @1;
        self.timestamp = [NSDate date];
        self.patientName =message.sender;
        
    }
    return self;
   
}
- (void)setDetailTextWithMediaType:(XHMessage *)message
{
    switch (message.messageMediaType) {
        case XHBubbleMessageMediaTypeText:
            self.detailText = message.text;
            break;
        case XHBubbleMessageMediaTypePhoto:
            self.detailText = @"图片";
            break;
        case XHBubbleMessageMediaTypeVideo:
            self.detailText = @"视频";
            break;
        case XHBubbleMessageMediaTypeVoice:
            self.detailText = @"语音";
            break;
            
        default:
            break;
    }

  
}

@end
